<template>
  <transition
    name="fade"
    enter-active-class="fadeInDown"
    leave-active-class="fadeOutUp"
  >
    <div id="refund" v-show="refundShow" :refundShow="refundShow">
      <div class="order-1">
        <div class="text">订单号：{{item.ordernumber}}</div>

      </div>
      <div class="order-1">
        <div class="text">名&nbsp;&nbsp;&nbsp;字：{{item.userName}}</div>

      </div>
      <div class="order-1">
        <div class="text">金&nbsp;&nbsp;&nbsp;额：{{item.orderGold}}</div>

      </div>
      <div class="order-1">
        <div class="text">充电桩：{{item.parkId}}</div>

      </div>
      <div class="order-1">
        <div class="text">端口号: {{item.portName}}</div>
      </div>
      <div class="order-1">
        <div class="text">退款额: </div>
        <input type="number" name v-model="item.refundAmount" placeholder="退款金额" class="my-input" />
      </div>

      <mu-button class="btn" @click="refundShow = false">取消</mu-button>
      <mu-button class="btn" @click="confimRefundHandler">确定</mu-button>
    </div>
  </transition>
</template>

<script>
  import { Toast } from "vant";
  import "vant/lib/toast/style/index";
  export default {
    data() {
      return {
        refundShow:false,
        item: {
          ordernumber: "",
          userName: "",
          price: "",
          parkId: "",
          portName: "",
          refundAmount: "",
        }
      };
    },
    methods: {
      Showrefunddiv(item) {
        this.refundShow = true;
        this.item={};
        this.item = item
      },
      confimRefundHandler(){
        if(this.item.refundAmount==''){
          Toast('请输入退款金额');
          return;
        }
        if (this.item.refundAmount*1 <= 0 || this.item.refundAmount*1 > this.item.orderGold*1) {
          Toast('退款金额不能大于订单金额');
          return;
        }

        var formDataRefund = {
          orderId : this.item.id,
          orderGold : this.item.orderGold,
          refundAmount:this.item.refundAmount
        };

        this.$api.refundOrder(formDataRefund).then(res=>{
          console.log(res);
          debugger
          if (res.data.message.code != 0) {
            Toast(res.data.message.message);
          } else {
            Toast('操作成功');
            this.refundShow = false;
          }
        })

      }
    }
  };
</script>

<style>
</style>
